import agconnect from "@hw-agconnect/api-ohos"
import '@hw-agconnect/core-ohos'
import '@hw-agconnect/function-ohos'

/**
 * 添加用户
 */
export const addUser = async  (payload) => {
  const functionCallable = agconnect.function().wrap("user-$latest")
  const result = await functionCallable.call({
    //操作类型 新增还是删除
    action: 'add',
    payload
  })

  return result.getValue()
}

/**
* 添加银行卡
*/
export const addBankCard = async  (payload) => {
  const functionCallable = agconnect.function().wrap("add-card-$latest")
  const result = await functionCallable.call({
    //操作类型 新增还是删除
    action: 'add',
    payload
  })

  return result.getValue()
}

/**
 * 获取银行卡信息
 */
export const queryBankCard = async  (payload) => {
  const functionCallable = agconnect.function().wrap("add-card-$latest")
  const result = await functionCallable.call({
    //操作类型 新增还是删除
    action: 'query',
    payload
  })

  return result.getValue()
}

/**
 * 获取用户信息
 */
export const queryUser= async  (payload) => {
  const functionCallable = agconnect.function().wrap("user-$latest")
  const result = await functionCallable.call({
    //操作类型 新增还是删除
    action: 'query',
    payload
  })

  return result.getValue()
}

/**
 * 更新用户信息
 */
export const patchUser= async  (payload) => {
  const functionCallable = agconnect.function().wrap("user-$latest")
  const result = await functionCallable.call({
    //操作类型 新增还是删除
    action: 'patch',
    payload
  })

  return result.getValue()
}